import random
#玩家和电脑出拳游戏

def computer_game(n, computer):
    if ((n == 1 and computer == 2)
            or (n == 2 and computer == 3)
            or (n == 3 and computer == 1)):

        print("用户赢了！")
    elif ((n == 1 and computer == 3)
              or (n == 2 and computer == 1)
              or (n == 3 and computer == 2)):

        print("电脑赢了！")
    elif (n == computer):
        print("平局！")
    else:
        print("猜拳无效！！！")


user_play = int(input("用户请输入猜拳序号数,1(石头)/2(剪刀)/3(布):"))
computer =random.randint(1,3)   #随机数使用
print("猜拳游戏开始！用户出%d,电脑出%d" % (user_play, computer))
computer_game(user_play, computer)

